﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DynamicOrderList.aspx.cs"
    Inherits="PeisongWeb.admin.DynamicOrderList" %>

<%@ Register TagName="top" Src="controls/top.ascx" TagPrefix="uc1" %>
<%@ Register TagName="menu" Src="controls/menu.ascx" TagPrefix="uc2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <!--#include file="style.inc"-->

    <script type="text/javascript" src="../app_common/scripts/jquery-cn.js"></script>

    <script type="text/javascript">
        function resetSrh() {
            document.getElementById("txt_company").value = "";
            document.getElementById("txt_orderNo").value = "";
            document.getElementById("ext_StartInputDt").value = "";
            document.getElementById("ext_EndInputDt").value = "";
            document.getElementById("ext_startReceiveDt").value = "";
            document.getElementById("ext_endReceiveDt").value = "";
            $('#txt_ProName').val('');
        }
        function checktxtlength(obj) {
            if (obj.value.length > 50) {
                obj.select();
                alert("输入长度请不要超过50个字符（一个汉字占两个字符）！");
            }
        }
        function checkCountNum(obj) {
            if (obj.value != "" && obj.value != "0") {
                var flag = IsPriceNumeric(obj.value);
                if (!flag)
                    obj.value = "1";
            }
            else
                obj.value = "1";
        }
        function checktxttype(obj) {
            var test = /^\d+(\.\d{1,2})?$/;
            if (test.test(obj.value)) {
                if (obj.value == "0") {
                    obj.value = "1"
                    return true;
                }
                else
                    return true;
            }
            else {
                obj.value = "1"
                return true;
            }
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="sm1" runat="server">
    </asp:ScriptManager>
    <ext:ScriptManager ID="ScriptManager1" runat="server" />
    <uc1:top ID="Top1" runat="server" />
    <uc2:menu ID="Menu1" runat="server" />
    <div id="admin-body">
        <h2 class="section-cms">
            提前下单列表
        </h2>
        <p>
            &nbsp;</p>
        <ext:Panel ID="Panel1" runat="server" Title="提前订单搜索" BodyStyle="padding:5px 5px 0"
            Width="1120px" Frame="true" ButtonAlign="Center">
            <Body>
                <div id="admin_edit_content_search">
                    <ul>
                        <li style="width: auto; margin-right: 20px">
                            <label>
                                企业名称
                            </label>
                            <asp:TextBox runat="server" ID="txt_company"></asp:TextBox>
                        </li>
                        <li style="width: auto; margin-right: 20px">
                            <label>
                                订单编号
                            </label>
                            <asp:TextBox runat="server" ID="txt_orderNo" Width="80px"></asp:TextBox>
                        </li>
                        <li style="width: auto; margin-left: 10px; padding-right: 20px">
                            <label>
                                商品名称
                            </label>
                            <asp:TextBox runat="server" ID="txt_ProName" Width="100px"></asp:TextBox>
                        </li>
                        <li style="width: 162px; padding-right: 20px;">
                            <label>
                                订单日期</label>
                            <ext:DateField ID="ext_StartInputDt" runat="server" AllowBlank="true" ReadOnly="true"
                                Width="100" />
                        </li>
                        <li style="width: auto; margin-right: 20px;">
                            <label style="width: 10px">
                                至</label>
                            <ext:DateField ID="ext_EndInputDt" ReadOnly="true" runat="server" Width="100" />
                        </li>
                        <li style="width:162px;padding-left:20px;">
                            <label>订单状态</label>
                            <asp:DropDownList runat="server" ID="ddlDynamicStatus">
                                <asp:ListItem Value="6" Selected="True">未转换</asp:ListItem>
                                <asp:ListItem Value="1">已提交</asp:ListItem>
                            </asp:DropDownList>
                        </li>
                        <li style="width: 162px; padding-left: 25px">
                            <label>
                                收货日期</label>
                            <ext:DateField ID="ext_startReceiveDt" runat="server" AllowBlank="true" ReadOnly="true"
                                Width="100" />
                        </li>
                        <li style="width: auto; float: left">
                            <label style="width: 10px">
                                至</label>
                            <ext:DateField ID="ext_endReceiveDt" runat="server" AllowBlank="true" ReadOnly="true"
                                Width="100" />
                        </li>
                        <li style="width: auto; padding-right: 150px">
                            <label>
                                &nbsp;</label>
                            [<asp:LinkButton ID="lbtn_Search" runat="server" Text="搜 索" OnClick="lbtn_Search_Click"
                                CausesValidation="false"></asp:LinkButton>]&nbsp;&nbsp;&nbsp; [<a href="javascript:resetSrh();">重
                                    置</a>] </li>
                    </ul>
                </div>
            </Body>
        </ext:Panel>
        <p>
            &nbsp;&nbsp;</p>
        <div id="admin_list_content" style="width: 1120px;">
            <table cellpadding="0" cellspacing="0">
                <tr class="header-row">
                    <th>
                        订单编号
                    </th>
                    <th>
                        总金额
                    </th>
                    <th>
                        企业编号
                    </th>
                    <th>
                        采购商
                    </th>
                    <th>
                        下单日期
                    </th>
                    <th>
                        收货日期
                    </th>
                    <th>
                        订单状态
                    </th>
                    <th>
                        修改状态时间
                    </th>
                    <th>
                        操作员
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                <asp:Repeater runat="server" ID="rpt_list" OnItemCommand="rpt_list_ItemCommand">
                    <ItemTemplate>
                        <tr class='<%# Container.ItemIndex%2==0? "row-alt":"alt"  %>'>
                            <td>
                                <%#DataBinder.Eval(Container.DataItem, "orderNo")%>
                            </td>
                            <td>
                                <%#DataBinder.Eval(Container.DataItem, "amount","{0:F2}")%>
                            </td>
                            <td>
                                <%#DataBinder.Eval(Container.DataItem, "companyNo")%>
                            </td>
                            <td>
                                <%#DataBinder.Eval(Container.DataItem, "company")%>
                            </td>
                            <td>
                                <%#DataBinder.Eval(Container.DataItem, "orderDt")%>
                            </td>
                            <td>
                                <%#DataBinder.Eval(Container.DataItem, "receiveDt")%>
                            </td>
                            <td>
                                <%#DataBinder.Eval(Container.DataItem, "orderStatus")%>
                            </td>
                            <td>
                                <%#DataBinder.Eval(Container.DataItem, "updateStatusdt")%>
                            </td>
                            <td>
                                <%#DataBinder.Eval(Container.DataItem, "username")%>
                            </td>
                            <td width="7%" height="26" align="center">
                                <asp:LinkButton CausesValidation="false" ID="lbn_details" runat="server" CommandName="details"
                                    CommandArgument='<%# Eval("orderid") %>' Text="编辑/查看">
                                </asp:LinkButton>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </table>
            <div id="page">
                <webdiyer:AspNetPager ID="AspNetPager1" NumericButtonType="Text" MoreButtonType="Text"
                    OnPageChanged="AspNetPager1_PageChanged" runat="server" AlwaysShow="True" PageSize="50"
                    InvalidPageIndexErrorMessage="无效页码" PageIndexOutOfRangeErrorMessage="页码超出范围"
                    ShowCustomInfoSection="Left" CustomInfoHTML=" 每页%PageSize%条记录 | 总共%RecordCount%条记录 "
                    CustomInfoTextAlign="Left" HorizontalAlign="Right" NextPageText="下一页" FirstPageText="首页"
                    LastPageText="末页" PrevPageText="上一页">
                </webdiyer:AspNetPager>
            </div>
        </div>
        <ext:Window ID="dynamicorder_details" runat="server" Title="提前订单详情" Height="550px"
            Width="920px" BodyStyle="padding: 6px; background-color: #fff;" AutoScroll="true"
            Modal="True" Resizable="false" ShowOnLoad="false" Draggable="false" Icon="ApplicationViewDetail">
            <Body>
                <asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
                    <Triggers>
                        <asp:PostBackTrigger ControlID="btn_Save" />
                        <asp:PostBackTrigger ControlID="lbn_Add" />
                        <asp:PostBackTrigger ControlID="btn_UpdateStatus" />
                        <asp:PostBackTrigger ControlID="rpt_DynamicOrderItems" />
                        <asp:PostBackTrigger ControlID="btn_UpdateOrder" />
                    </Triggers>
                    <ContentTemplate>
                        <div class="details">
                            <h2>
                                <asp:Label runat="server" ID="lbl_OrderNo"></asp:Label>
                            </h2>
                            <hr />
                            <ul>
                                <li>
                                    <label>
                                        订单状态：</label>
                                    <asp:TextBox runat="server" ID="txt_status" ReadOnly="true" Width="55px"></asp:TextBox>
                                    <span style="<%=isUnderTransfer?"": "display:none" %>">
                                        <asp:Button runat="server" ID="btn_UpdateStatus" Text="关闭本次交易" OnClick="btn_UpdateStatus_Click"
                                            CausesValidation="false" Width="90px"/>
                                    </span></li>
                                <li>
                                    <label>
                                        交易关闭原因：</label>
                                    <asp:TextBox runat="server" ID="txt_closeReason" Rows="3" Columns="20" TextMode="MultiLine"
                                        MaxLength="500"></asp:TextBox>
                                    <input id="hd_orderid" runat="server" type="hidden" />
                                    <input id="hd_customerid" runat="server" type="hidden" />
                                    <input id="hd_companyid" runat="server" type="hidden" />
                                </li>
                                <li>
                                    <label>
                                        下单日期：</label>
                                    <asp:Label runat="server" ID="lbl_orderDt"></asp:Label>
                                </li>
                                <li>
                                    <label>
                                        汇总总价：</label>
                                    <asp:Label runat="server" ID="lbl_StandardAmount"></asp:Label>
                                </li>
                                <li>
                                    <label>
                                        客户备注：</label>
                                    <asp:Label runat="server" ID="lbl_Note"></asp:Label>
                                </li>
                                <li>
                                    <label>
                                        收货时间：</label>
                                    <span style="float: left">
                                        <ext:DateField ID="ext_receiveDt" runat="server" AllowBlank="true" ReadOnly="true" />
                                    </span>
                                    <%-- <ext:TimeField ID="ext_receiveTime" Width="60px" runat="server" MinTime="7:00" MaxTime="19:00"
                                        Increment="5" SelectedTime="07:00" Format="H:mm" />--%>
                                    <asp:DropDownList runat="server" ID="ddl_receiveTime" DataTextField="name" DataValueField="xm">
                                    </asp:DropDownList>
                                    <%--     <asp:DropDownList runat="server" ID="ddl_receiveTime">
                                        <asp:ListItem Value="7">7:00</asp:ListItem>
                                        <asp:ListItem Value="8">8:00</asp:ListItem>
                                        <asp:ListItem Value="9">9:00</asp:ListItem>
                                        <asp:ListItem Value="10">10:00</asp:ListItem>
                                        <asp:ListItem Value="11">11:00</asp:ListItem>
                                        <asp:ListItem Value="12">12:00</asp:ListItem>
                                        <asp:ListItem Value="13">13:00</asp:ListItem>
                                        <asp:ListItem Value="14">14:00</asp:ListItem>
                                        <asp:ListItem Value="15">15:00</asp:ListItem>
                                        <asp:ListItem Value="16">16:00</asp:ListItem>
                                        <asp:ListItem Value="17">17:00</asp:ListItem>
                                        <asp:ListItem Value="18">18:00</asp:ListItem>
                                        <asp:ListItem Value="19">19:00</asp:ListItem>
                                    </asp:DropDownList>--%>
                                </li>
                                <li>
                                    <label>
                                        客服备注：</label>
                                    <asp:TextBox runat="server" ID="txt_serviceNote" Rows="3" Columns="20" TextMode="MultiLine"
                                        MaxLength="500"></asp:TextBox>
                                </li>
                                
                            </ul>
                            <span style="<%=isUnderTransfer?"": "display:none" %>">
                                    <asp:Button runat="server" ID="btn_UpdateOrder" Text="修改订单基本信息" OnClick="btn_UpdateOrder_Click" CausesValidation="false" />
                            </span>
                            <p>
                                &nbsp;</p>
                            <table width="98%" border="0" cellpadding="4" cellspacing="1" style="text-align: left">
                                <tr>
                                    <td>
                                        <h2>
                                            商品信息
                                        </h2>
                                        <hr />
                                    </td>
                                </tr>
                            </table>
                            <table width="98%" border="0" cellpadding="4" cellspacing="1" bgcolor="#99BBE8" style="text-align: left">
                                <tr align="center" style="height: 20px;">
                                    <td bgcolor="#C0D5F0">
                                        商品编号
                                    </td>
                                    <td bgcolor="#C0D5F0">
                                        级别
                                    </td>
                                    <td bgcolor="#C0D5F0">
                                        商品名称
                                    </td>
                                    <td bgcolor="#C0D5F0">
                                        预定数量
                                    </td>
                                    <td bgcolor="#C0D5F0">
                                        数量
                                    </td>
                                    <td bgcolor="#C0D5F0">
                                        备注
                                    </td>
                                    <td bgcolor="#C0D5F0">
                                        预定价格
                                    </td>
                                    <td bgcolor="#C0D5F0">
                                        现价
                                    </td>
                                    <td bgcolor="#C0D5F0">
                                        总价
                                    </td>
                                    <td bgcolor="#C0D5F0">
                                        操作
                                    </td>
                                </tr>
                                <asp:Repeater runat="server" ID="rpt_DynamicOrderItems" OnItemCommand="rpt_DynamicOrderItems_ItemCommand">
                                    <ItemTemplate>
                                        <tr align="center" style="height: 20px;">
                                            <td bgcolor="#FFFFFF">
                                                <%#DataBinder.Eval(Container.DataItem, "productNo")%>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <%#DataBinder.Eval(Container.DataItem, "businessnatureName")%>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <%#DataBinder.Eval(Container.DataItem, "name")%>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <%#DataBinder.Eval(Container.DataItem, "initQuantity")%>
                                                <%#DataBinder.Eval(Container.DataItem, "unit")%>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <asp:TextBox ID="txt_quantity" MaxLength="10" Width="50" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "quantity")%>' onblur='checktxttype(this);'></asp:TextBox>
                                                <%#DataBinder.Eval(Container.DataItem, "unit")%>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <asp:TextBox ID="txtNote" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "note")%>'></asp:TextBox>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <%#DataBinder.Eval(Container.DataItem, "orderprice","{0:F2}")%>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <%#DataBinder.Eval(Container.DataItem, "nowprice","{0:F2}")%>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <%#DataBinder.Eval(Container.DataItem, "amount","{0:F2}")%>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <span style="<%=isUnderTransfer?"display:block": "display:none" %>">
                                                    <asp:LinkButton CommandName="Del" OnClientClick="return confirm('你确定要删除吗?');" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"oiid") %>'
                                                        runat="server" ID="lblDel">删除</asp:LinkButton>
                                                    <asp:LinkButton ID="lbt_Remarks" runat="server" CommandName="ReamrksEdit" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"oiid") %>'
                                                        Text="修改">
                                                    </asp:LinkButton>
                                                </span>
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:Repeater>
                                <tr align="center" style="height: 20px;">
                                    <td colspan="9">
                                    </td>
                                    <td bgcolor="#FFFFFF">
                                        <span style="<%=isUnderTransfer?"display:block": "display:none" %>">
                                            <asp:LinkButton ID="lbn_Add" runat="server" Text="添加商品" OnClick="lbn_Add_Click" CausesValidation="false">
                                            </asp:LinkButton>
                                        </span>
                                    </td>
                                </tr>
                            </table>
                            <b>
                                    <asp:Button runat="server" ID="btn_Save" Text="生成正式订单" OnClick="btn_Save_Click"/>
                            </b>
                            <br />
                            <p>
                                &nbsp;</p>
                            <h2>
                                收货信息</h2>
                            <hr />
                            <ul>
                                <li>
                                    <label>
                                        公司名称：</label>
                                    <asp:Label runat="server" ID="lbl_company"></asp:Label>
                                    <asp:HiddenField runat="server" ID="hdCompanyNature" />
                                </li>
                                <li style="width: 500px">
                                    <label>
                                        收货人姓名：</label>
                                    <asp:Label runat="server" ID="lbl_contact"></asp:Label>
                                </li>
                                <li>
                                    <label>
                                        联系方式：</label>
                                    <asp:Label runat="server" ID="lbl_contactMobile"></asp:Label>
                                    <asp:Label runat="server" ID="lbl_contactPhone"></asp:Label>
                                </li>
                                <li class="long">
                                    <label>
                                        收货地址：
                                    </label>
                                    <asp:Label runat="server" ID="lbl_Address"></asp:Label>
                                </li>
                            </ul>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </Body>
        </ext:Window>
        <ext:Window ID="product_add" runat="server" Title="添加商品" Height="550px" Width="900px"
            BodyStyle="padding: 6px; background-color: #fff;" AutoScroll="true" Modal="True"
            Resizable="false" ShowOnLoad="false" Draggable="false" Icon="ApplicationViewDetail">
            <Body>
                <asp:UpdatePanel runat="server" ID="up1" UpdateMode="Conditional">
                    <Triggers>
                        <asp:PostBackTrigger ControlID="lbn_AddOrderItem" />
                    </Triggers>
                    <ContentTemplate>
                        <div class="details">
                            <table width="98%" border="0" cellpadding="4" cellspacing="1" style="text-align: left">
                                <tr>
                                    <td style="width: 18%">
                                        <label>
                                            大 类：</label>
                                        <asp:DropDownList runat="server" ID="ddl_CategoryRoot" DataTextField="name" DataValueField="categoryId"
                                            AutoPostBack="True" OnSelectedIndexChanged="ddl_CategoryRoot_SelectedIndexChanged">
                                        </asp:DropDownList>
                                    </td>
                                    <td style="width: 18%">
                                        <label>
                                            小 类：</label>
                                        <asp:DropDownList runat="server" ID="ddl_CategorySub" DataTextField="name" DataValueField="categoryId">
                                        </asp:DropDownList>
                                    </td>
                                    <td style="width: 18%">
                                        商品编号:<asp:TextBox ID="txt_ProductNo" runat="server" Width="80px"></asp:TextBox>
                                    </td>
                                    <td style="width: 18%">
                                        商品名称:<asp:TextBox ID="txt_ProductName" runat="server" Width="80px"></asp:TextBox>
                                    </td>
                                    <td style="width: 7%">
                                        <asp:LinkButton ID="lbn_search" runat="server" Text="［搜索］" CausesValidation="false"
                                            OnClick="lbn_search_Click">
                                        </asp:LinkButton>
                                    </td>
                                    <td align="right">
                                        <asp:LinkButton ID="lbn_AddOrderItem" runat="server" Text="［添加到订单］" CausesValidation="false"
                                            OnClick="lbn_AddOrderItem_Click">
                                        </asp:LinkButton>
                                        <asp:LinkButton ID="lbl_cancel" runat="server" Text="［取消］" CausesValidation="false"
                                            OnClick="lbl_cancel_Click">
                                        </asp:LinkButton>
                                    </td>
                                </tr>
                            </table>
                            <table width="98%" border="0" cellpadding="4" cellspacing="1" bgcolor="#99BBE8" style="text-align: left">
                                <tr align="center" style="height: 20px;">
                                    <td width="8%" bgcolor="#C0D5F0">
                                        商品编号
                                    </td>
                                    <td width="20%" bgcolor="#C0D5F0">
                                        商品名称
                                    </td>
                                    <td width="12%" bgcolor="#C0D5F0">
                                        商品价格
                                    </td>
                                    <td width="10%" bgcolor="#C0D5F0">
                                        商品等级
                                    </td>
                                    <td width="8%" bgcolor="#C0D5F0">
                                        数量
                                    </td>
                                    <td width="20%" bgcolor="#C0D5F0">
                                        备注
                                    </td>
                                    <td width="10%" bgcolor="#C0D5F0">
                                        选择
                                    </td>
                                </tr>
                                <asp:Repeater runat="server" ID="rpt_Products">
                                    <ItemTemplate>
                                        <tr align="center" style="height: 20px;">
                                            <td bgcolor="#FFFFFF">
                                                <%# Eval("productNo")%>
                                                <asp:HiddenField ID="hid_productId" runat="server" Value='<%#Eval("productId") %>' />
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <a target="_blank" href="../user_productDetail_<%#Eval("productId")%>.html">
                                                    <asp:Label runat="server" ID="lbl_proName" Text='<%# Eval("Name")%>'></asp:Label>
                                                </a>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <span style='<%#Convert.ToInt32(Eval("isCurrentCost"))==1?"": "display:none"%>; color: Red'>
                                                    时价</span> ￥<asp:Label runat="server" ID="lbl_price" Text='<%#string.Format("{0:F2}", Eval("newprice"))%>'></asp:Label>
                                                /
                                                <asp:Label runat="server" ID="lbl_unit" Text='<%#Eval("unit")%>'></asp:Label>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <asp:Label runat="server" ID="lbl_Nature" Text='<%#Eval("NatureCode")%>'></asp:Label>
                                                <asp:HiddenField ID="hidNature" runat="server" Value='<%#Eval("businessNature") %>' />
                                            </td>
                                            <td bgcolor="#FFFFFF" align="center">
                                                <asp:TextBox ID="txtQuantity" onblur='checktxttype(this);' 
                                                    runat="server" Text="1" MaxLength="8" Width="60px"></asp:TextBox>
                                            </td>
                                            <td bgcolor="#FFFFFF">
                                                <asp:TextBox ID="txtNote" runat="server" Width="150px" MaxLength="200" onblur='checktxtlength(this);' Text='<%# Eval("remarks") %>'></asp:TextBox>
                                            </td>
                                            <td bgcolor="#FFFFFF" align="center">
                                                <asp:CheckBox ID="cbx_isUser" runat="server" />
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </table>
                            <div>
                                <webdiyer:AspNetPager ID="AspNetPager3" NumericButtonType="Text" MoreButtonType="Text"
                                    runat="server" AlwaysShow="False" PageSize="20" InvalidPageIndexErrorMessage="无效页码"
                                    PageIndexOutOfRangeErrorMessage="页码超出范围" ShowCustomInfoSection="Left" CustomInfoHTML=" 每页%PageSize%条记录 | 总共%RecordCount%条记录 "
                                    CustomInfoTextAlign="Left" HorizontalAlign="Right" OnPageChanged="AspNetPager3_PageChanged"
                                    NextPageText="下一页" FirstPageText="首页" LastPageText="末页" PrevPageText="上一页">
                                </webdiyer:AspNetPager>
                            </div>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </Body>
        </ext:Window>
    </div>
    </form>
</body>
</html>
